package Control;

import Model.DBUtil;

import java.util.ArrayList;
import java.util.HashSet;

public class MyRunnable implements Runnable {
    //用一个集合来存储当前数据库已经有的的车辆信息
    private static HashSet<Car> carHashSet = new HashSet<>();

    //新建一个线程来提高从数据库读取数据的速度
    private static MyRunnable myRunnable;
    private static Thread tCarlist;

    @Override
    public void run() {
            DBUtil.getData(carHashSet);
    }

    public void CarlistRun(){
        DBUtil.getData(carHashSet);
        System.out.println("ok");
    }
    //重置当前显示的集合的数据
    public static void clearCarHashSet(){
        carHashSet.clear();
    }

    public static HashSet<Car> getCarlist() {
        return carHashSet;
    }

    //获取主方法创建的集合对象
    public static HashSet<Car> getMyrun(){
        return myRunnable.getCarlist();
    }

    public static MyRunnable getMyRunnable() {
        return myRunnable;
    }

    public static void catListLoad(){
        tCarlist.start();
    }

}
